package com.bl.basic.interceptor.config;

import com.bl.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration // 相当于当前类是配置了 差不多是一个xml
public class MyCongig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) // 使用拦截器
        // 拦截路径
        .addPathPatterns("/**") // 拦截所有请求
                // 放行的请求
                .excludePathPatterns("/fastDfs/**")//店铺入驻需要的图片上传
                .excludePathPatterns("/login/**")//登录页面
         .excludePathPatterns("/user/registered")//用户注册
                .excludePathPatterns("/shop/settlement")//店铺入驻
                .excludePathPatterns("/verifyCode/**")//用户注册验证码
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**");// 放行路径swagger测试
    }
}
